<admintpl file="header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('Distribution/index')}">配送时间列表</a></li>
			<li class="active"><a href="{:U('Distribution/add')}">添加配送时间</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form" action="{:U('Distribution/add_post')}">
			<fieldset>
				<div class="control-group">
					<label class="control-label"><b style="color:red;">* </b> 区域</label>
					<div class="controls">
						<select name="city_id" id="city_id" onchange="cityname()">
							<option value="">请选择</option>
							<foreach name="city" item="vo">
								<option value="{$vo.city_id}">{$vo.city_name}</option>
							</foreach>
							<input type="hidden" id="city_name" name="city_name" value="">
						</select>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label"><b style="color:red;">* </b> 截单时间</label>
					<div class="controls">
						<input type="text" id="time" name="time">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label"><b style="color:red;">* </b> 天数</label>
					<div class="controls">
						<input type="text" name="day">
					</div>
				</div>
				<div class="control-group" id="timediv">
					<label class="control-label"><b style="color:red;">* </b> 配送时间跨度</label>
					<div class="controls">
						<input type="text" class="distributiontime" name="start_time[]" placeholder="开始时间" style="width: 80px;"> -
						<input type="text" class="distributiontime" name="end_time[]" placeholder="结束时间" style="width: 80px;">
						<a class="btn btn-success" style="font-size: 20px;" onclick="addtime()">+</a>
					</div>
				</div>

				<div class="control-group">
					<label class="control-label">{:L('STATUS')}</label>
					<div class="controls">
						<label class="radio inline" for="active_true"><input type="radio" name="use_flg" value="1" checked id="active_true" />{:L('ENABLED')}</label>
						<label class="radio inline" for="active_false"><input type="radio" name="use_flg" value="0" id="active_false">{:L('DISABLED')}</label>
					</div>
				</div>
			</fieldset>
			<div class="form-actions">
				<button type="submit" class="btn btn-primary">{:L('ADD')}</button>
				<a class="btn" href="javascript:history.back(-1);">{:L('BACK')}</a>
			</div>
		</form>
	</div>
	<script>
        function cityname(){
            var name = $("#city_id").find("option:selected").text();
            $("#city_name").val(name);
        }
        $("#time").datetimepicker({
            autoclose: true,
            maxView:1,
            startView: 1,
            language: 'zh-CN',
            format: 'hh:ii'
        })
        function addtime(){
            var text = "<div class='controls' style='margin-top: 10px'> <input type='text' class='distributiontime'  name='start_time[]' placeholder='开始时间' style='width: 80px;'> - <input type='text' class='distributiontime' name='end_time[]' placeholder='结束时间' style='width: 80px;'> <a class='btn btn-danger' style='font-size: 20px; width: 15px' onclick='deletediv(this)'>-</a> </div>";
			$("#timediv").append(text);
            $(".distributiontime").datetimepicker({
                autoclose: true,
                maxView:1,
                startView: 1,
                language: 'zh-CN',
                format: 'hh:ii'
            })
		}
        function deletediv(a){
            $(a).parent().remove();
		}

		$(function () {
            $(".distributiontime").datetimepicker({
                autoclose: true,
                maxView:1,
                startView: 1,
                language: 'zh-CN',
                format: 'hh:ii'
            })
        })
	</script>
	<script src="__PUBLIC__/js/common.js"></script>
</body>
</html>